package testjava;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class TestApp extends BaseTest {

	public static void main(String[] args) throws Exception {
		Integer i = null;
		if (1 == i) {
			System.out.println("sss");
		}
	}

	private static void testSMTP() {
		String host = "192.168.15.154";// "smtp.163.com";// "localhost";//
										// "10.234.74.186";//
										// "192.168.16.93";//
		// //"127.0.0.1";//
		//
		String user = "fucheng";// "jacky_liu_cn@163.com";//
		String password = null;// "Lfc_1979";// "fucheng";// "abc";
		String from = "caretrack@caretrackvolvo.cn";// user;//
		// "fucheng.liu@volvo.com";//
		String to = "fucheng.liu@volvo.com";
		String subject = "Java Mail Example! from local";
		String body = "host:" + host + ",user:" + user;

		try {
			Properties props = new Properties();
			props.put("mail.smtp.host", host);
			if (password != null) {
				props.put("mail.smtp.auth", "true");
			}
			Session ssn = Session.getInstance(props, null);

			MimeMessage message = new MimeMessage(ssn);

			InternetAddress fromAddress = new InternetAddress(from);
			message.setFrom(fromAddress);
			InternetAddress toAddress = new InternetAddress(to);
			message.addRecipient(Message.RecipientType.TO, toAddress);

			message.setSubject(subject);
			message.setText(body);

			Transport transport = ssn.getTransport("smtp");
			if (password != null) {
				transport.connect(host, user, password);
			} else {
				transport.connect();
			}
			transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
			// transport.send(message);
			transport.close();

		} catch (Exception m) {
			m.printStackTrace();
		}
	}

	public void print(String str) {
		int a = 10;
		int b = 11;
		if (a > 0 | b++ < 100) {
			System.out.println(str + ' ' + b);
		}
	}
}
